import { Controller, Get, Post, Body, Patch, Param, Delete, ValidationPipe } from '@nestjs/common';
import { BlogService } from './blog.service';
import { CategoryDto } from './dto/categoryDto.dto';
import { Public } from 'src/utils/public';
import { BlogDto } from './dto/blogDto.dto';

@Controller('blog')
export class BlogController {
  constructor(private readonly blogService: BlogService) {}

  @Post('category/add')
  @Public()
  createCategory(@Body(ValidationPipe) CategoryDto: CategoryDto) {
    return this.blogService.createCategory(CategoryDto);
  }

  @Get('category/list')
  @Public()
  getCategoryList() {
    return this.blogService.getCategoryList();
  }

  @Post('category/update')
  @Public()
  updateCategory(@Body() CategoryDto: CategoryDto) {
    return this.blogService.updateCategory(CategoryDto);
  }

  @Delete('category/:id')
  @Public()
  deleteCategory(@Param('id') id: string) {
    return this.blogService.deleteCategory(+id);
  }


  @Post('tag/add')
  @Public()
  createTag(@Body() tagDto:any) {
    return this.blogService.createTag(tagDto);
  }

  @Get('tag/list')
  @Public()
  getTagList() {
    return this.blogService.getTagList();
  }

  @Post('tag/update')
  @Public()
  updateTag(@Body() obj: any) {
    return this.blogService.updateTag(obj);
  }

  @Delete('tag/:id')
  @Public()
  deleteTag(@Param('id') id: string) {
    return this.blogService.deleteTag(+id);
  }


  @Post('add')
  @Public()
  createBlog(@Body() blogDto:BlogDto) {
    return this.blogService.createBlog(blogDto);
  }

  @Get('tag/list')
  @Public()
  getBlogList() {
    return this.blogService.getBlogList();
  }

  @Post('tag/update')
  @Public()
  updateBlog(@Body() obj: any) {
    return this.blogService.updateBlog(obj);
  }

  @Delete('tag/:id')
  @Public()
  deleteBlog(@Param('id') id: string) {
    return this.blogService.deleteBlog(+id);
  }

}
